package server.messageContent;

import common.Constants;
import common.DeserializationManager;
import common.data.MonitorArgs;
import common.interfaces.MessageContent;

//This class is used to extract the contend from an array of byte msg from client
//For Monitor Server, the data just contains monitor interval (in millisecond)
public class MonitorMsgContent extends MonitorArgs implements MessageContent {
	public MonitorMsgContent(byte[] data) {
		int currentIndex = 0;

		byte[] timeLengthStream = new byte[Constants.INT_LENGTH];
		System.arraycopy(data, currentIndex, timeLengthStream, 0, Constants.INT_LENGTH);
		int timeLength = DeserializationManager.getCurrent().toInt(timeLengthStream);
		currentIndex += Constants.INT_LENGTH;
		
		byte[] timeStream = new byte[timeLength];
		System.arraycopy(data, currentIndex, timeStream, 0, timeLength);
		this.setTime(DeserializationManager.getCurrent().toLong(timeStream));
		currentIndex += timeLength;		
	}
	
	@Override
	public byte[] getByte() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int getLength() {
		// TODO Auto-generated method stub
		return 0;
	}

}
